app.controller("gouwucheCtrl",["$scope",'adBuy','selectService','count',
function($scope,adBuy,selectService,count){
	$scope.data = adBuy.data;
	$scope.adBuy =adBuy;
	$scope.state = true;
	$scope.fun3 = function(i,num){
		if(i.num){
			i.num += num;
		}else{
			i.num = 1;
		}
		adBuy.addCar(i,i.text);
		$scope.total += i.price*num;
		count.countFn();
	}
	
	$scope.total = 0; 
	$scope.fun4 = function(total){
		for(var i in $scope.data){
			if ($scope.data[i].num!=undefined) {
				$scope.total += ($scope.data[i].num)*(parseFloat($scope.data[i].price));
			}	
		}
	}
	$scope.fun4();
	
	$scope.selectAll = function(){
		selectService.selectAll($scope.state);
	}
	
	$scope.selectFn = function(){
		$scope.state = selectService.selectFn();
	}
	
}])